<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2024/1/30
 * Time: 上午10:12
 */

namespace App\Tools\Astrolog;

/**
 * Class Forecast
 * @package App\Tools\Astrolog
 */
class Forecast
{
    protected $solarReturn = [];

    public function init($record = [], $category = [])
    {
        // 星盘配置
        $setting = [
            // 太阳返照盘-单盘
            'solar_return' => [
                'planet' => [
                    [1, 8.5], [1, 7.5], [1, 3.5], [1, 3.5], [1, 4], [1, 4.5], [1, 4.5], [1, 2.5], [1, 2.5], [1, 2.5],
                    [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [1, 2.5], [1, 2.5], [1, 2.5], [1, 2.5]
                ],
                'phase' => [
                    0 => [1, 0], 60 => [1, 0], 90 => [1, 0], 120 => [1, 0], 180 => [1, 0],
                    45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [0, 0], 72 => [0, 0], 144 => [0, 0]
                ],
                'arabic' => [
                    [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                    [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                    [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
                ],
                'h_sys' => 'p',
                'firdaria' => 'default',
                'bound_type' => 'default',
                'ecliptic' => 0,
                'profection_push_direction' => 0,
                'decanates' => 0,
                'ayanamsa' => 0,
                'location_use' => 0,// 现居地
            ],
        ];

        $now = time();
        $advance = [
            'year' => (int)date('Y', $now),
            'month' => (int)date('n', $now),
            'day' => (int)date('d', $now),
            'hour' => (int)date('H', $now),
            'minute' => (int)date('i', $now),
            'timezone' => 8,
            'is_summer' => 0,
        ];

        Astrolog::getInstance()->setExecPrefix(config('astrolog.prefix'))
            ->setIsAstrolabe(false)
            ->setRecode1($record)
            ->setUserSetting($setting)
            ->setGetDatas(['solar_return']);

        Astrolog::getInstance()->setAdvance($advance)->getAstroDatas();
        $this->solarReturn = Astrolog::getInstance()->getDatas('solar_return');
        $percent = [];
        foreach ($category as $k1 => $v1)
        {
            if (isset($v1['category']))
            {
                $percent[] = $this->getTypeData($v1);
            }
        }
        $per = 55;
        if (!empty($percent))
        {
            $per = array_sum($percent) / count($percent);
        }
        return $per;
    }

    public function getTypeData($category)
    {
        // 0=>婚恋 1=>桃花 2=>感情 3=>正财 4=>偏财 5=>破财 6=>健康 7=>生活家庭 8=>事业 9=>考试 10=>学历提升 11=>出行 12=>其他类
        # 类别 0=>婚恋 1=>桃花 2=>感情 3=>财富整体 4=>正财 5=>偏财 6=>破财 7=>健康 8=>生活家庭 9=>事业 10=>考试 11=>学历提升 12=>出行 13=>其他类

        switch ($category['category'])
        {
            case 0:
                $res = $this->getHunlian();
                break;
            case 1:
                $res = $this->getTaohuachengdu();
                break;
            case 2:
                // 问题正向负向 0=> 负向 1=> 正向
                if ($category['pos_or_neg'])
                {
                    $res = $this->getGanqingshunli();
                } else
                {
                    $res = $this->getGanqingkunnan();
                }
                break;
            case 3:
                $res = $this->getCaifuzhengti();
                break;
            case 4:
                $res = $this->getZhengcai();
                break;
            case 5:
                $res = $this->getPiancai();
                break;
            case 6:
                $res = $this->getPocai();
                break;
            case 7:
                $res = $this->getJiankang();
                break;
            case 8:
                $res = $this->getShenghuo();
                break;
            case 9:
                $res = $this->getShiye();
                break;
            case 10:
                $res = $this->getKaoshishunli();
                break;
            case 11:
                $res = $this->getXuelitisheng();
                break;
            case 12:
                $res = $this->getChuxing();
                break;
            default:
                $res = 55;
                break;
        }
        if ($res < 10)
        {
            $res = 10;
        }
        return $res;
    }

    /**
     * 婚恋概率
     * @return int
     */
    protected function getHunlian(): int
    {
        /**
         * 婚恋（整体）
         * 7宫主不被火星/土星/冥王星刑克/对分 1
         * 7宫主不被8宫主/12宫主刑克/对分 1
         * 金星不被火星/土星/冥王星刑克/对分 1
         * 金星不被8宫主/12宫主刑克/对分 1
         * 7宫主与金星合相/三合/六合 2
         * 7宫主与月亮三合/六合 1
         * 7宫主与太阳三合/六合 1
         * 5宫主与金星合相/三合/六合 2
         * 5宫主与月亮三合/六合 1
         * 5宫主与太阳三合/六合 1
         * 7宫主不落12宫 1
         * 5宫主不落12宫 1
         * 7宫主不落8宫 1
         * 5宫主不落8宫 1
         * 7宫主与1宫主互溶（非刑克）/接纳（非刑克） 2
         * 7宫主与4宫主互溶（非刑克）/接纳（非刑克） 2
         * 金星与木星三合/六合/接纳（非刑克）/互溶（非刑克） 2
         * 金星与天王星合相/三合/六合 1
         * 金星落5宫/7宫 1
         */
        $rule = [
            0 => 1, 1 => 1, 2 => 1, 3 => 1, 4 => 2, 5 => 1,
            6 => 1, 7 => 2, 8 => 1, 9 => 1, 10 => 1, 11 => 1,
            12 => 1, 13 => 1, 14 => 2, 15 => 2, 16 => 2, 17 => 1, 18 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect4 = $this->solarReturn['houses'][4]['protect_ancient_id'];// 4宫主
        $protect5 = $this->solarReturn['houses'][5]['protect_ancient_id'];// 5宫主
        $protect7 = $this->solarReturn['houses'][7]['protect_ancient_id'];// 7宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if (!$this->isPlanetPkPlanet($protect7, 4, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, 6, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, 9, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if (!$this->isPlanetPkPlanet($protect7, $protect8, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, $protect12, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if (!$this->isPlanetPkPlanet(3, 4, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 6, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 9, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if (!$this->isPlanetPkPlanet(3, $protect8, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, $protect12, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[3];
        }
        if ($this->isPlanetPkPlanet($protect7, 3, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetPkPlanet($protect7, 1, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetPkPlanet($protect7, 0, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetPkPlanet($protect5, 3, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetPkPlanet($protect5, 1, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if ($this->isPlanetPkPlanet($protect5, 0, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[9];
        }
        if (!$this->isPlanetInHouse($protect7, 12, $this->solarReturn['planets']))
        {
            $score += $rule[10];
        }
        if (!$this->isPlanetInHouse($protect5, 12, $this->solarReturn['planets']))
        {
            $score += $rule[11];
        }
        if (!$this->isPlanetInHouse($protect7, 8, $this->solarReturn['planets']))
        {
            $score += $rule[12];
        }
        if (!$this->isPlanetInHouse($protect5, 8, $this->solarReturn['planets']))
        {
            $score += $rule[13];
        }
        if ($this->isPlanetAcceptPlanet($protect7, $protect1, $this->solarReturn))
        {
            $score += $rule[14];
        }
        if ($this->isPlanetAcceptPlanet($protect7, $protect4, $this->solarReturn))
        {
            $score += $rule[15];
        }
        if ($this->isPlanetPkPlanet(3, 5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet(3, 5, $this->solarReturn))
        {
            $score += $rule[16];
        }
        if ($this->isPlanetPkPlanet(3, 7, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[17];
        }
        if ($this->isPlanetInHouse(3, 5, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(3, 7, $this->solarReturn['planets']))
        {
            $score += $rule[18];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 桃花程度
     * @return int
     */
    protected function getTaohuachengdu(): int
    {
        /**
         * 桃花程度
         * 金星与木星三合/六合/接纳/互溶 2
         * 金星与5宫主三合/六合/接纳/互溶 2
         * 金星与7宫主三合/六合/接纳/互溶 1
         * 金星与1宫主三合/六合/接纳/互溶 2
         * 金星落5宫/7宫 2
         * 木星落5宫/7宫2
         * 金星落1宫 1
         * 7宫主落1宫 1
         * 1宫主落7宫 1
         * 1宫主落5宫 1
         */
        $rule = [
            0 => 2, 1 => 2, 2 => 1, 3 => 2, 4 => 2, 5 => 2,
            6 => 1, 7 => 1, 8 => 1, 9 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect5 = $this->solarReturn['houses'][5]['protect_ancient_id'];// 5宫主
        $protect7 = $this->solarReturn['houses'][7]['protect_ancient_id'];// 7宫主
        if ($this->isPlanetPkPlanet(3, 5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet(3, 5, $this->solarReturn, []))
        {
            $score += $rule[0];
        }
        if ($this->isPlanetPkPlanet(3, $protect5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet(3, $protect5, $this->solarReturn, []))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetPkPlanet(3, $protect7, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet(3, $protect7, $this->solarReturn, []))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet(3, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet(3, $protect1, $this->solarReturn, []))
        {
            $score += $rule[3];
        }
        if ($this->isPlanetInHouse(3, 5, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(3, 7, $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetInHouse(5, 5, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(5, 7, $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetInHouse(3, 1, $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetInHouse($protect7, 1, $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetInHouse($protect1, 7, $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if ($this->isPlanetInHouse($protect1, 5, $this->solarReturn['planets']))
        {
            $score += $rule[9];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 感情顺利
     * @return int
     */
    protected function getGanqingshunli(): int
    {
        /**
         * 感情顺利
         * 7宫主不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 2
         * 金星不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 2
         * 太阳月亮三合/六合 2
         * 7宫主与1宫主三合/六合/互溶（非刑克）/接纳（非刑克） 2
         * 5宫内没有火星/土星/冥王星 2
         * 7宫主不落陷 1
         */
        $rule = [
            0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 2, 5 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect7 = $this->solarReturn['houses'][7]['protect_ancient_id'];// 1宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if (!$this->isPlanetPkPlanet($protect7, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect7, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if (!$this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetPkPlanet(0, 1, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet($protect7, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect7, $protect1, $this->solarReturn))
        {
            $score += $rule[3];
        }
        if (!$this->isPlanetInHouse(4, 5, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(6, 5, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 5, $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetPromote($protect7, $this->solarReturn['planets']) === 2)
        {
            $score += $rule[5];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 感情困难
     * @return int
     */
    protected function getGanqingkunnan(): int
    {
        /**
         * 感情困难
         * 7宫主被火星/土星刑克 2
         * 7宫主被8宫主/12宫主刑克 2
         * 7宫主被天王星/冥王星刑克 1
         * 金星被火星/土星刑克 2
         * 金星被8宫主/12宫主刑克 2
         * 金星被天王星/冥王星刑克 1
         * 太阳与月亮刑克/对分 2
         * 7宫主与1宫主刑克/对分 2
         * 5宫内有火星/土星/冥王星 2
         * 7宫内有火星/土星/冥王星 2
         */
        $rule = [
            0 => 2, 1 => 2, 2 => 1, 3 => 2, 4 => 2, 5 => 1,
            6 => 2, 7 => 2, 8 => 2, 9 => 2
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect7 = $this->solarReturn['houses'][7]['protect_ancient_id'];// 7宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 9宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if ($this->isPlanetPkPlanet($protect7, 4, [90], $this->solarReturn)
            || $this->isPlanetPkPlanet($protect7, 6, [90], $this->solarReturn))
        {
            $score += $rule[0];
        }
        if ($this->isPlanetPkPlanet($protect7, $protect8, [90], $this->solarReturn)
            || $this->isPlanetPkPlanet($protect7, $protect12, [90], $this->solarReturn))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetPkPlanet($protect7, 7, [90], $this->solarReturn)
            || $this->isPlanetPkPlanet($protect7, 9, [90], $this->solarReturn))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn)
            || $this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn))
        {
            $score += $rule[3];
        }
        if ($this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn)
            || $this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetPkPlanet(3, 7, [90], $this->solarReturn)
            || $this->isPlanetPkPlanet(3, 9, [90], $this->solarReturn))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetPkPlanet(0, 1, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetPkPlanet($protect7, $protect1, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetInHouse(4, 5, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(6, 5, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(9, 5, $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if ($this->isPlanetInHouse(4, 7, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(6, 7, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(9, 7, $this->solarReturn['planets']))
        {
            $score += $rule[9];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 财富整体
     * @return int
     */
    protected function getCaifuzhengti(): int
    {
        /**
         * 财富整体
         * 2宫内没有火星/土星 1
         * 5宫内没有火星/土星 1
         * 8宫内没有火星/土星 1
         * 2宫主不被火星/土星刑克 1
         * 5宫主不被火星/土星刑克 1
         * 8宫主不被火星/土星刑克 1
         * 2宫内有木星 2
         * 2宫内有金星 2
         * 5宫内有木星 2
         * 5宫内有金星 2
         * 8宫内有木星 2
         * 8宫内有金星 2
         * 2宫主与金星三合/六合 2
         * 2宫主与木星三合/六合 2
         * 2宫主与5宫主三合/六合/互溶（非刑克）/接纳（非刑克） 2
         */
        $rule = [
            0 => 1, 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1,
            6 => 2, 7 => 2, 8 => 2, 9 => 2, 10 => 2, 11 => 2,
            12 => 2, 13 => 2, 14 => 2
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect2 = $this->solarReturn['houses'][2]['protect_ancient_id'];// 2宫主
        $protect5 = $this->solarReturn['houses'][5]['protect_ancient_id'];// 5宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        if (!$this->isPlanetInHouse(4, 2, $this->solarReturn['planets'])
            || !$this->isPlanetInHouse(6, 2, $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if (!$this->isPlanetInHouse(4, 5, $this->solarReturn['planets'])
            || !$this->isPlanetInHouse(6, 5, $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if (!$this->isPlanetInHouse(4, 8, $this->solarReturn['planets'])
            || !$this->isPlanetInHouse(6, 8, $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if (!$this->isPlanetPkPlanet($protect2, 4, [90], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect2, 6, [90], $this->solarReturn['planets']))
        {
            $score += $rule[3];
        }
        if (!$this->isPlanetPkPlanet($protect5, 4, [90], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect5, 6, [90], $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if (!$this->isPlanetPkPlanet($protect8, 4, [90], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect8, 6, [90], $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetInHouse(5, 2, $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetInHouse(3, 2, $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetInHouse(5, 5, $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if ($this->isPlanetInHouse(3, 5, $this->solarReturn['planets']))
        {
            $score += $rule[9];
        }
        if ($this->isPlanetInHouse(5, 8, $this->solarReturn['planets']))
        {
            $score += $rule[10];
        }
        if ($this->isPlanetInHouse(3, 8, $this->solarReturn['planets']))
        {
            $score += $rule[11];
        }
        if ($this->isPlanetPkPlanet($protect2, 3, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[12];
        }
        if ($this->isPlanetPkPlanet($protect2, 5, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[13];
        }
        if ($this->isPlanetPkPlanet($protect2, $protect5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect2, $protect5, $this->solarReturn))
        {
            $score += $rule[14];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 正财
     * @return int
     */
    protected function getZhengcai(): int
    {
        /**
         * 正财
         * 2宫主在1宫且不被火星/土星/8宫主/12宫主刑克 1
         * 2宫主在2宫且不被火星/土星/8宫主/12宫主刑克 1
         * 2宫主与5宫主三合/六合/接纳（非刑克）/互溶（非刑克） 2
         * 2宫主与木星三合/六合/接纳（非刑克）/互溶（非刑克） 2
         * 木星在2宫且不被火星、土星/8宫主/12宫主刑克 2
         * 金星在2宫且不被火星、土星/8宫主/12宫主刑克 2
         * 1宫主在2宫且不被火星、土星/8宫主/12宫主刑克 2
         * 2宫主与1宫主三合/六合/接纳（非刑克）/互溶（非刑克） 2
         * 2宫主与11宫主三合/六合/接纳（非刑克）/互溶（非刑克） 2
         */
        $rule = [
            0 => 1, 1 => 1, 2 => 2, 3 => 2, 4 => 2,
            5 => 2, 6 => 2, 7 => 2, 8 => 2
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect2 = $this->solarReturn['houses'][2]['protect_ancient_id'];// 2宫主
        $protect5 = $this->solarReturn['houses'][5]['protect_ancient_id'];// 5宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect11 = $this->solarReturn['houses'][11]['protect_ancient_id'];// 11宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if ($this->isPlanetInHouse($protect2, 1, $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if ($this->isPlanetInHouse($protect2, 2, $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect2, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetPkPlanet($protect2, $protect5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect2, $protect5, $this->solarReturn))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet($protect2, 5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect2, 5, $this->solarReturn))
        {
            $score += $rule[3];
        }
        if ($this->isPlanetInHouse(5, 2, $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(5, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(5, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(5, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(5, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetInHouse(3, 2, $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetInHouse($protect1, 2, $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetPkPlanet($protect2, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect2, $protect1, $this->solarReturn))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetPkPlanet($protect2, $protect11, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect2, $protect11, $this->solarReturn))
        {
            $score += $rule[8];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 偏财
     * @return int
     */
    protected function getPiancai(): int
    {
        /**
         * 偏财
         * 木星在5宫/8宫且不被火星、土星/8宫主/12宫主刑克 2
         * 金星在5宫/8宫且不被火星、土星/8宫主/12宫主刑克 2
         * 1宫主在5宫/8宫且不被火星/土星/8宫主/12宫主刑克 1
         * 1宫主与5宫主三合/六合/接纳（非刑克）/互溶（非刑克） 1
         * 1宫主与8宫主三合/六合/接纳（非刑克）/互溶（非刑克） 1
         * 2宫主与8宫主三合/六合/接纳（非刑克）/互溶（非刑克） 2
         * 2宫主与5宫主三合/六合/接纳（非刑克）/互溶（非刑克） 2
         */
        $rule = [
            0 => 2, 1 => 2, 2 => 1, 3 => 1, 4 => 1, 5 => 2, 6 => 2
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect2 = $this->solarReturn['houses'][2]['protect_ancient_id'];// 2宫主
        $protect5 = $this->solarReturn['houses'][5]['protect_ancient_id'];// 5宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if (($this->isPlanetInHouse(5, 5, $this->solarReturn['planets'])
                || $this->isPlanetInHouse(5, 8, $this->solarReturn['planets']))
            && !$this->isPlanetPkPlanet(5, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(5, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(5, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(5, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if (($this->isPlanetInHouse(3, 5, $this->solarReturn['planets'])
                || $this->isPlanetInHouse(3, 8, $this->solarReturn['planets']))
            && !$this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if (($this->isPlanetInHouse($protect1, 5, $this->solarReturn['planets'])
                || $this->isPlanetInHouse($protect1, 8, $this->solarReturn['planets']))
            && !$this->isPlanetPkPlanet($protect1, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet($protect1, $protect5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect1, $protect5, $this->solarReturn))
        {
            $score += $rule[3];
        }
        if ($this->isPlanetPkPlanet($protect1, $protect8, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect1, $protect8, $this->solarReturn))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetPkPlanet($protect2, $protect8, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect2, $protect8, $this->solarReturn))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetPkPlanet($protect2, $protect5, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect2, $protect5, $this->solarReturn))
        {
            $score += $rule[6];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 破财
     * @return int
     */
    protected function getPocai(): int
    {
        /**
         * 破财
         * 土星/火星在8宫 2
         * 冥王星在8宫 1
         * 土星/火星在2宫 2
         * 冥王星在2宫 1
         * 土星/火星在5宫 2
         * 冥王星在5宫 1
         * 金星被火星/土星/8宫主/12宫主刑克 2
         * 2宫主被火星/土星/8宫主/12宫主刑克 2
         * 5宫主被火星/土星/8宫主/12宫主刑克 2
         * 2宫主被冥王星刑克 1
         * 5宫主被冥王星刑克 1
         */
        $rule = [
            0 => 2, 1 => 1, 2 => 2, 3 => 1, 4 => 2, 5 => 1,
            6 => 2, 7 => 2, 8 => 2, 9 => 1, 10 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect2 = $this->solarReturn['houses'][2]['protect_ancient_id'];// 2宫主
        $protect5 = $this->solarReturn['houses'][5]['protect_ancient_id'];// 5宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 8宫主
        if ($this->isPlanetInHouse(4, 8, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(6, 8, $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if ($this->isPlanetInHouse(9, 8, $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetInHouse(4, 2, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(6, 2, $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetInHouse(9, 2, $this->solarReturn['planets']))
        {
            $score += $rule[3];
        }
        if ($this->isPlanetInHouse(4, 5, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(6, 5, $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetInHouse(9, 5, $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetPkPlanet($protect2, 4, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect2, 6, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect2, $protect8, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect2, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetPkPlanet($protect5, 4, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect5, 6, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect5, $protect8, [90], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect5, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if ($this->isPlanetPkPlanet($protect2, 9, [90], $this->solarReturn['planets']))
        {
            $score += $rule[9];
        }
        if ($this->isPlanetPkPlanet($protect5, 9, [90], $this->solarReturn['planets']))
        {
            $score += $rule[10];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 健康
     * @return int
     */
    protected function getJiankang(): int
    {
        /**
         * 健康
         * 命主星不被火星/土星刑克/对分 1
         * 命主星不被8宫主/12宫主刑克/对分 1
         * 命主星不被6宫主刑克1
         * 命主星不在6宫/8宫/12宫 1
         * 太阳不被火星/土星刑克/对分 1
         * 太阳不被8宫主/12宫主刑克/对分1
         * 太阳不被6宫主刑克 1
         * 太阳不在6宫/8宫/12宫 1
         * 月亮不被火星/土星刑克/对分 1
         * 月亮不被8宫主/12宫主刑克/对分 1
         * 月亮不被6宫主刑克 1
         * 月亮不在6宫/8宫/12宫 1
         * 6宫内没有火星/土星/冥王星 1
         * 6宫内没有8宫主/12宫主 1
         * 8宫内没有火星/土星/冥王星 1
         * 8宫内没有8宫主/12宫主 1
         */
        $rule = [
            0 => 1, 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1,
            6 => 1, 7 => 1, 8 => 1, 9 => 1, 10 => 1, 11 => 1,
            12 => 1, 13 => 1, 14 => 1, 15 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect6 = $this->solarReturn['houses'][6]['protect_ancient_id'];// 6宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if (!$this->isPlanetPkPlanet($protect1, 4, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, 6, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if (!$this->isPlanetPkPlanet($protect1, $protect8, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect1, $protect12, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if (!$this->isPlanetPkPlanet($protect1, $protect6, [90], $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if (!$this->isPlanetInHouse($protect1, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse($protect1, 8, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse($protect1, 12, $this->solarReturn['planets']))
        {
            $score += $rule[3];
        }
        if (!$this->isPlanetPkPlanet(0, 4, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(0, 6, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if (!$this->isPlanetPkPlanet(0, $protect8, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(0, $protect12, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if (!$this->isPlanetPkPlanet(0, $protect6, [90], $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if (!$this->isPlanetInHouse(0, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(0, 8, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(0, 12, $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if (!$this->isPlanetPkPlanet(1, 4, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(1, 6, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if (!$this->isPlanetPkPlanet(1, $protect8, [90, 180], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(1, $protect12, [90, 180], $this->solarReturn['planets']))
        {
            $score += $rule[9];
        }
        if (!$this->isPlanetPkPlanet(1, $protect6, [90], $this->solarReturn['planets']))
        {
            $score += $rule[10];
        }
        if (!$this->isPlanetInHouse(1, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(1, 8, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(1, 12, $this->solarReturn['planets']))
        {
            $score += $rule[11];
        }
        if (!$this->isPlanetInHouse(4, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(6, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 6, $this->solarReturn['planets']))
        {
            $score += $rule[12];
        }
        if (!$this->isPlanetInHouse($protect8, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse($protect12, 6, $this->solarReturn['planets']))
        {
            $score += $rule[13];
        }
        if (!$this->isPlanetInHouse(4, 8, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(6, 8, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 8, $this->solarReturn['planets']))
        {
            $score += $rule[14];
        }
        if (!$this->isPlanetInHouse($protect8, 8, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse($protect12, 8, $this->solarReturn['planets']))
        {
            $score += $rule[15];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 生活/家庭
     * @return int
     */
    protected function getShenghuo(): int
    {
        /**
         * 生活/家庭
         * 4宫主不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 2
         * 4宫主与1宫主三合/六合/互溶(非刑克)/接纳(非刑克) 2
         * 4宫内没有火星/土星/冥王星 2
         * 4宫内有太阳/木星/金星 2
         * 4宫内星不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 1
         */
        $rule = [
            0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect4 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 4宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if (!$this->isPlanetPkPlanet($protect4, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect4, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect4, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect4, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect4, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect4, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if ($this->isPlanetPkPlanet($protect4, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect4, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[1];
        }
        if (!$this->isPlanetInHouse(4, 4, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(6, 4, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 4, $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }

        if ($this->isPlanetInHouse(0, 4, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(3, 4, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(5, 4, $this->solarReturn['planets']))
        {
            $score += $rule[3];
        }
        if (($this->isPlanetInHouse(0, 4, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(1, 4, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(2, 4, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(3, 4, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(4, 4, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(5, 4, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(6, 4, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, $protect12, [90], $this->solarReturn['planets'])))
        {
            $score += $rule[4];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 事业
     * @return int
     */
    protected function getShiye(): int
    {
        /**
         * 事业
         * 10宫主不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 2
         * 10宫内没有火星/土星/冥王星 2
         * 10宫内有太阳/木星/金星 2
         * 10宫主与1宫主三合/六合/互溶(非刑克)/接纳(非刑克) 2
         * 10宫内星不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 1
         * 6宫主不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 2
         * 6宫主与1宫主三合/六合/互溶(非刑克)/接纳(非刑克) 2
         * 6宫内没有火星/土星/冥王星 2
         * 6宫内有太阳/木星/金星 2
         * 6宫内星不被火星/土星/天王星/冥王星/8宫主/12宫主刑克 1
         * 10宫内有1宫主 1
         * 1宫内有10宫主 1
         */
        $rule = [
            0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 1, 5 => 2,
            6 => 2, 7 => 2, 8 => 2, 9 => 1, 10 => 1, 11 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect6 = $this->solarReturn['houses'][6]['protect_ancient_id'];// 6宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect10 = $this->solarReturn['houses'][10]['protect_ancient_id'];// 10宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if (!$this->isPlanetPkPlanet($protect10, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect10, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect10, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect10, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect10, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect10, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if (!$this->isPlanetInHouse(4, 10, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(6, 10, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 10, $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetInHouse(0, 10, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(3, 10, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(5, 10, $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet($protect10, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect10, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[3];
        }
        if (($this->isPlanetInHouse(0, 10, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(1, 10, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(2, 10, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(3, 10, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(4, 10, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(5, 10, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(6, 10, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, $protect12, [90], $this->solarReturn['planets'])))
        {
            $score += $rule[4];
        }
        if (!$this->isPlanetPkPlanet($protect6, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect6, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect6, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect6, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect6, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect6, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetPkPlanet($protect6, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect6, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[6];
        }
        if (!$this->isPlanetInHouse(4, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(6, 6, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 6, $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetInHouse(0, 6, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(3, 6, $this->solarReturn['planets'])
            || $this->isPlanetInHouse(5, 6, $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if (($this->isPlanetInHouse(0, 6, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(0, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(1, 6, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(1, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(2, 6, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(2, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(3, 6, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(3, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(4, 6, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(4, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(5, 6, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(5, $protect12, [90], $this->solarReturn['planets']))
            || ($this->isPlanetInHouse(6, 6, $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 4, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 6, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 7, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, 9, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, $protect8, [90], $this->solarReturn['planets'])
                && !$this->isPlanetPkPlanet(6, $protect12, [90], $this->solarReturn['planets'])))
        {
            $score += $rule[9];
        }
        if ($this->isPlanetInHouse($protect1, 10, $this->solarReturn['planets']))
        {
            $score += $rule[10];
        }
        if ($this->isPlanetInHouse($protect10, 1, $this->solarReturn['planets']))
        {
            $score += $rule[11];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 考试顺利程度
     * @return int
     */
    protected function getKaoshishunli(): int
    {
        /**
         * 考试顺利程度
         * 3宫主与太阳/月亮/金星/木星/水星合相/三合/六合 2
         * 9宫主与太阳/月亮/金星/木星/水星合相/三合/六合 2
         * 3宫主不被火星/土星/天王星/海王星/冥王星/8宫主/12宫主刑克 1
         * 9宫主不被火星/土星/天王星/海王星/冥王星/8宫主/12宫主刑克 1
         * 3宫主不落陷 1
         * 9宫主不落陷 1
         * 3宫主与1宫主三合/六合/互溶（非刑克）/接纳（非刑克） 2
         * 9宫主与1宫主三合/六合/互溶（非刑克）/接纳（非刑克） 2
         * 3宫内无土星/冥王星 1
         * 9宫内无土星/冥王星 1
         * 3宫内有太阳 2
         * 3宫内有木星 2
         * 9宫内有太阳 2
         * 9宫内有木星 2
         */
        $rule = [
            0 => 2, 1 => 2, 2 => 1, 3 => 1, 4 => 1, 5 => 1,
            6 => 2, 7 => 2, 8 => 1, 9 => 1, 10 => 2, 11 => 2,
            12 => 2, 13 => 2
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect3 = $this->solarReturn['houses'][3]['protect_ancient_id'];// 3宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect9 = $this->solarReturn['houses'][9]['protect_ancient_id'];// 9宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if ($this->isPlanetPkPlanet($protect3, 0, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 1, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 2, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 3, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 5, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if ($this->isPlanetPkPlanet($protect9, 0, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 1, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 2, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 3, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 5, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetPkPlanet($protect3, 4, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 6, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 7, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 8, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, 9, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, $protect8, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect3, $protect12, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet($protect9, 4, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 6, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 7, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 8, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 9, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, $protect8, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, $protect12, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[3];
        }
        if ($this->isPlanetPromote($protect3, $this->solarReturn['planets']) !== 2)
        {
            $score += $rule[4];
        }
        if ($this->isPlanetPromote($protect9, $this->solarReturn['planets']) !== 2)
        {
            $score += $rule[5];
        }
        if ($this->isPlanetPkPlanet($protect3, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect3, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetPkPlanet($protect9, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect9, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[7];
        }
        if (!$this->isPlanetInHouse(6, 3, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 3, $this->solarReturn['planets']))
        {
            $score += $rule[8];
        }
        if (!$this->isPlanetInHouse(6, 9, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 9, $this->solarReturn['planets']))
        {
            $score += $rule[9];
        }
        if ($this->isPlanetInHouse(0, 3, $this->solarReturn['planets']))
        {
            $score += $rule[10];
        }
        if ($this->isPlanetInHouse(5, 3, $this->solarReturn['planets']))
        {
            $score += $rule[11];
        }
        if ($this->isPlanetInHouse(0, 9, $this->solarReturn['planets']))
        {
            $score += $rule[12];
        }
        if ($this->isPlanetInHouse(5, 9, $this->solarReturn['planets']))
        {
            $score += $rule[13];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 学历提升
     * @return int
     */
    protected function getXuelitisheng(): int
    {
        /**
         * 学历提升
         * 9宫主与太阳/月亮/金星/木星/水星合相/三合/六合 2
         * 9宫主不被火星/土星/天王星/海王星/冥王星/8宫主/12宫主刑克 1
         * 9宫主不落陷 1
         * 9宫主与1宫主三合/六合/互溶（非刑克）/接纳（非刑克） 2
         * 9宫内无土星/冥王星 1
         * 9宫内有太阳 2
         * 9宫内有木星 2
         * 9宫内有1宫主 2
         */
        $rule = [
            0 => 2, 1 => 1, 2 => 1, 3 => 2, 4 => 1, 5 => 2,
            6 => 2, 7 => 2
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect9 = $this->solarReturn['houses'][9]['protect_ancient_id'];// 9宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if ($this->isPlanetPkPlanet($protect9, 0, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 1, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 2, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 3, [0, 60, 120], $this->solarReturn['planets'])
            || $this->isPlanetPkPlanet($protect9, 5, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if (!$this->isPlanetPkPlanet($protect9, 4, [0, 60, 120], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect9, 6, [0, 60, 120], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect9, 7, [0, 60, 120], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect9, 8, [0, 60, 120], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect9, 9, [0, 60, 120], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect9, $protect8, [0, 60, 120], $this->solarReturn['planets'])
            || !$this->isPlanetPkPlanet($protect9, $protect12, [0, 60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetPromote($protect9, $this->solarReturn['planets']) !== 2)
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet($protect9, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect9, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[3];
        }
        if (!$this->isPlanetInHouse(6, 9, $this->solarReturn['planets'])
            && !$this->isPlanetInHouse(9, 9, $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if ($this->isPlanetInHouse(0, 9, $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if ($this->isPlanetInHouse(5, 9, $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetInHouse($protect1, 9, $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 出行
     * @return int
     */
    protected function getChuxing(): int
    {
        /**
         * 出行
         * 3宫主不被火星/土星/天王星/海王星/冥王星/8宫主/12宫主刑克 1
         * 3宫主与太阳/月亮/金星/木星/水星合相/三合/六合 2
         * 3宫主不落陷 1
         * 3宫主与1宫主三合/六合/互溶（非刑克）/接纳（非刑克） 2
         * 水星不被火星/土星/天王星/海王星/冥王星/8宫主/12宫主刑克 1
         * 3宫内没有火星/土星 1
         * 9宫主不被火星/土星/天王星/海王星/冥王星/8宫主/12宫主刑克 1
         * 9宫主与太阳/月亮/金星/木星合相/三合/六合 2
         * 9宫主不落陷 1
         * 9宫主与1宫主三合/六合/互溶（非刑克）/接纳（非刑克） 2
         * 9宫内没有火星/土星 1
         */
        $rule = [
            0 => 1, 1 => 2, 2 => 1, 3 => 2, 4 => 1, 5 => 1,
            6 => 1, 7 => 2, 8 => 1, 9 => 2, 10 => 1
        ];
        $score = 0; // 初始化得分
        $sum = array_sum($rule); // 计算总分数
        $protect1 = $this->solarReturn['houses'][1]['protect_ancient_id'];// 1宫主
        $protect3 = $this->solarReturn['houses'][3]['protect_ancient_id'];// 3宫主
        $protect8 = $this->solarReturn['houses'][8]['protect_ancient_id'];// 8宫主
        $protect9 = $this->solarReturn['houses'][9]['protect_ancient_id'];// 9宫主
        $protect12 = $this->solarReturn['houses'][12]['protect_ancient_id'];// 12宫主
        if (!$this->isPlanetPkPlanet($protect3, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect3, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect3, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect3, 8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect3, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect3, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect3, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[0];
        }
        if ($this->isPlanetPkPlanet($protect3, 0, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect3, 1, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect3, 2, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect3, 3, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect3, 5, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[1];
        }
        if ($this->isPlanetPromote($protect3, $this->solarReturn['planets']) !== 2)
        {
            $score += $rule[2];
        }
        if ($this->isPlanetPkPlanet($protect3, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect3, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[3];
        }
        if (!$this->isPlanetPkPlanet(2, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(2, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(2, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(2, 8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(2, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(2, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet(2, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[4];
        }
        if (!$this->isPlanetInHouse(4, 3, $this->solarReturn['planets'])
            || !$this->isPlanetInHouse(6, 3, $this->solarReturn['planets']))
        {
            $score += $rule[5];
        }
        if (!$this->isPlanetPkPlanet($protect9, 4, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect9, 6, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect9, 7, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect9, 8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect9, 9, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect9, $protect8, [90], $this->solarReturn['planets'])
            && !$this->isPlanetPkPlanet($protect9, $protect12, [90], $this->solarReturn['planets']))
        {
            $score += $rule[6];
        }
        if ($this->isPlanetPkPlanet($protect9, 0, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect9, 1, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect9, 2, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect9, 3, [60, 120], $this->solarReturn['planets'])
            && $this->isPlanetPkPlanet($protect9, 5, [60, 120], $this->solarReturn['planets']))
        {
            $score += $rule[7];
        }
        if ($this->isPlanetPromote($protect9, $this->solarReturn['planets']) !== 2)
        {
            $score += $rule[8];
        }
        if ($this->isPlanetPkPlanet($protect9, $protect1, [60, 120], $this->solarReturn['planets'])
            || $this->isPlanetAcceptPlanet($protect9, $protect1, $this->solarReturn, [90]))
        {
            $score += $rule[9];
        }
        if (!$this->isPlanetInHouse(4, 9, $this->solarReturn['planets'])
            || !$this->isPlanetInHouse(6, 9, $this->solarReturn['planets']))
        {
            $score += $rule[11];
        }
        return $this->getPercent($score, $sum);
    }

    /**
     * 是否成相
     * @param int $p1 行星ID
     * @param int $p2 行星ID
     * @param array $phase 相位
     * @param array $planets 行星数据
     * @return bool
     */
    private function isPlanetPkPlanet(int $p1, int $p2, array $phase, array $planets): bool
    {
        $key = $p1 . '-' . $p2;
        return isset($planets[$p1]['phase'][$key]) && in_array($planets[$p1]['phase'][$key]['phase_e'], $phase, true);
    }

    /**
     * 是否落宫
     * @param int $p1
     * @param int $hid
     * @param array $planets
     * @return bool
     */
    private function isPlanetInHouse(int $p1, int $hid, array $planets): bool
    {
        return $planets[$p1]['in_house_id'] === $hid;
    }

    /**
     * 是否非刑相 互容/接纳
     * @param int $p1 行星ID1
     * @param int $p2 行星ID2
     * @param array $data 星盘数据
     * @param int[] $expectPhase 排除相位
     * @return bool
     */
    private function isPlanetAcceptPlanet(int $p1, int $p2, array $data, $expectPhase = [90]): bool
    {
//        $receptOrMutualRecept = Astrolog::getInstance()->receptOrMutualRecept($data['planets']);
        if (empty($expectPhase) || !$this->isPlanetPkPlanet($p1, $p2, $expectPhase, $data['planets']))
        {
            // 判断是否接纳
            if (isset($data['characteristic']) && empty($data['characteristic']))
            {
                if (isset($data['characteristic'][1]) && !empty($data['characteristic'][1]))
                {
                    foreach ($data['characteristic'][1] as $k1 => $v1)
                    {
                        if (($v1['id1'] === $p1 && $v1['id2'] === $p2)
                            || ($v1['id1'] === $p2 && $v1['id2'] === $p1))
                        {
                            return true;
                        }
                    }
                }
                // 判断是否互容
                if (isset($data['characteristic'][2]) && !empty($data['characteristic'][2]))
                {
                    foreach ($data['characteristic'][2] as $k1 => $v1)
                    {
                        if (($v1['id1'] === $p1 && $v1['id2'] === $p2)
                            || ($v1['id1'] === $p2 && $v1['id2'] === $p1))
                        {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

    /**
     * 获取行星是否擢升/落陷
     * @param int $p1 行星ID
     * @param array $planets 行星数据
     * @return int 1 擢升 2 落陷 -1 不存在
     */
    private function isPlanetPromote(int $p1, array $planets): int
    {
        return $planets[$p1]['ancient']['promote'];
    }

    /**
     * 计算概率 例如：83
     * @param $score int 分数
     * @param $sum int 总分
     * @return int
     */
    protected function getPercent($score, $sum): int
    {
        return (int)($score / $sum * 100);
    }
}